package com.itwill.ecom.category;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


@Repository("categoryDao")
public class CategoryDaoImpl implements CategoryDao {
	public final static String namespace="com.itwill.ecom.category.CategoryMapper";

	public CategoryDaoImpl() {
	
	}
	@Autowired
	private SqlSession session;
	
	public SqlSession getSession() {
		return session;
	}
	public void setSession(SqlSession session) {
		this.session = session;
		System.out.println("CategorySession 셋합니다잉");
	}

	
	//// 카테고리 생성 ////
	@Override
	public int createCategory(CategoryBeans categoryBeans) {
		return session.insert(namespace+".createCategory",categoryBeans);
	}
	
	//// 카테고리 검색 ////
	@Override
	public CategoryBeans getCategory(int category_no) {
		return session.selectOne(namespace+".selectOneCategory", category_no);
	}
	//// 카테고리 전체검색 ////
	@Override
	public List<CategoryBeans> getAllCategory() {
		return session.selectList(namespace+".listCategory");
	}
	//// 카테고리 수정 ////
	@Override
	public int updateCategory(CategoryBeans categoryBeans) {
		return session.update(namespace+".updateCategory", categoryBeans);
	}
	//// 카테고리 삭제 ////
	@Override
	public int deleteCategory(int category_no) {
		return session.delete(namespace+".deleteCategory", category_no);
	}
}
